﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace ConceptCorporateAdmin
{
    public class DbEntitate : DbObject
    {
        private int id, idTipEntitate, idActNormativ, nrOrdine;
        private String nume, ultimaModificare, fisierContinut;

        protected override string getTableName()
        {
            return "entitati";
        }

        public String getRtfText()
        {
            String ret = "";
            try
            {
                StreamReader sr = new StreamReader("database/files/" + FisierContinut);
                ret    = sr.ReadToEnd();
                sr.Close();
            }
            catch (Exception ex)
            {
                throw ex;   
            }
            return ret;
        }
        public override void Delete()
        {
            base.Delete();
            //sterge si fisierul rtf asociat
            if( File.Exists("database/files/" + FisierContinut) )
                File.Delete("database/files/"+FisierContinut);
        }
        #region properties
        public int NrOrdine
        {
            get { return nrOrdine; }
            set { nrOrdine = value; }
        }

        public int IdActNormativ
        {
            get { return idActNormativ; }
            set { idActNormativ = value; }
        }

        public int IdTipEntitate
        {
            get { return idTipEntitate; }
            set { idTipEntitate = value; }
        }

        public int Id
        {
            get { return id; }
            set { id = value; }
        }


        public String Nume
        {
            get { return nume; }
            set { nume = value; }
        }


        public string UltimaModificare
        {
            get { return ultimaModificare; }
            set { ultimaModificare = value; }
        }

        public String FisierContinut
        {
            get { return fisierContinut; }
            set { fisierContinut = value; }
        }
        #endregion
    }
}
